<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>js实现酷炫导航</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            text-decoration: none;
        }

        #wrapper {
            width: 900px;
            height: 50px;
            background-color: beige;
            margin: 100px auto 0;
        }

        #wrapper ul {
            list-style: none;
            font-size: 18px;
            font-weight: 500;
            line-height: 50px;
            margin-left: 50px;
        }

        #wrapper ul li {
            width: 70px;
            float: left;
            padding: 0 20px;
            text-align: center;
        }

        #wrapper ul li.current {
            background-color: #ff00ff;
            transition: 1.3s ease-in-out;
        }
    </style>
</head>

<body>
    <div id="wrapper">
        <ul id="nav">
            <li class="current"><a href="#">首页</a></li>
            <li><a href="#">HTML</a></li>
            <li><a href="#">CSS</a></li>
            <li><a href="#">JavaScript</a></li>
            <li><a href="#">Node.js</a></li>
            <li><a href="#">jQuery</a></li>
            <li><a href="#">About</a></li>
        </ul>
    </div>
    <script>
        var oLi = document.getElementById('nav').getElementsByTagName('li');
        for (var i = 0; i < oLi.length; i++) {
            var aObjs = oLi[i].firstElementChild;
            aObjs.onmouseover = function () {
                for (var j = 0; j < oLi.length; j++) {
                    oLi[j].removeAttribute('class');
                    }
                this.parentNode.className = "current";
            }
        }
    </script>
</body>

</html>